package com.xz.courseschedule.controller;

import com.xz.courseschedule.common.vo.UserVo;
import com.xz.courseschedule.entity.User;
import com.xz.courseschedule.service.UserService;
import com.xz.courseschedule.utils.Result;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 用户管理控制器
 * @Author: zys
 * @CreateTime: 2025-05-22
 */
@Tag(name = "用户管理", description = "用户认证和信息管理")
@RestController
@RequestMapping("/user")
public class UserController {

    @Autowired
    private UserService userService;

    @Operation(summary = "获取用户信息", description = "获取当前用户的基本信息")
    @GetMapping("/index")
    public Result index(){
        User user = userService.getById(1L);
        return Result.success(user);
    }

    @Operation(summary = "用户登录", description = "用户登录验证，返回登录结果和用户信息")
    @PostMapping("/login")
    public Result login(@RequestBody UserVo userVo){
        return userService.login(userVo);
    }
}
